<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="error.jsp" %>
<%@ page import="function.Message"%>
<%@ page import="show.Msg_show"%>
<%@ page import="function.Open"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:useBean class="show.Detail_show" id="det" scope="request" />
<jsp:useBean class="show.Main_show" id="mai" scope="request" />
<script src="../js/table.js" type="text/javascript"></script>
<script language="javascript">
window.onload = function()
{
	page = new Page(15,"people","peo_name");
}
</script>
</head>

<body background="../image/1e2fd93e770d85b6a2cc2b59.jpg">
<%
	request.setCharacterEncoding("utf-8");
	String transid = request.getParameter("transid");
	String author = null;
	String txt = request.getParameter("txt");
	int getid = 0;
	if(transid != null)
	{
		author = (String)session.getAttribute("name");
		getid = Integer.parseInt(transid);
//		out.print("<script>alert('"+getid+"');</script>");
//		out.print("<script>alert('"+txt+"');</script>");
		Message m = new Message(getid,author,txt);
		m.add();
	}
%>
<%
		String user = (String)session.getAttribute("name");
		boolean isLog = false;
		if(user != null)
		{
			isLog = true;
		}
		int id = Integer.parseInt(request.getParameter("id"));
		int index = det.getID().indexOf(id);
		String name = (String)det.getNAME().get(index);
		if(isLog)
		{
		out.print("<div id='tableDiv' style='position:absolute;left:10px;top:0px'><font color='red' size='+1'><b><table align='center'>");
		//在这儿改变字体或者其它什么的你想改变的↑
		out.print("<tr><td style='color:#0000FF'>姓名</td><td>"+mai.getNAME().get(index)+"</td><td></td><td></td></tr>");
		out.print("<tr><td></td><td></td><td style='color:#0000FF'>电话</td><td>"+mai.getTEL().get(index)+"</td></tr>");
		out.print("<tr><td style='color:#0000FF'>电邮</td><td>"+mai.getMAIL().get(index)+"</td><td></td><td></td></tr>");
		out.print("<tr><td></td><td></td><td style='color:#0000FF'>性别</td><td>"+mai.getSEX().get(index)+"</td></tr>");
		out.print("<tr><td style='color:#0000FF'>住址</td><td>"+mai.getLOCAL().get(index)+"</td><td></td><td></td></tr>");
		out.print("<tr><td></td><td></td><td style='color:#0000FF'>QQ</td><td>"+mai.getQQ().get(index)+"</td></tr>");
		out.print("<tr><td style='color:#0000FF'>父亲</td><td>"+det.getPA().get(index)+"</td><td></td><td></td></tr>");
		out.print("<tr><td></td><td></td><td style='color:#0000FF'>母亲</td><td>"+det.getMA().get(index)+"</td></tr>");
		out.print("<tr><td style='color:#0000FF'>小学</td><td>"+det.getPRIMARY().get(index)+"</td><td></td><td></td></tr>");
		out.print("<tr><td></td><td></td><td style='color:#0000FF'>初中</td><td>"+det.getMIDDLE().get(index)+"</td></tr>");
		out.print("<tr><td style='color:#0000FF'>高中</td><td>"+det.getHIGH().get(index)+"</td><td></td><td></td></tr>");
		out.print("<tr><td></td><td></td><td style='color:#0000FF'>食物</td><td>"+det.getFOOD().get(index)+"</td></tr>");
		out.print("<tr><td style='color:#0000FF'>生日</td><td>"+mai.getBIRTH().get(index)+"</td><td></td><td></td></tr>");
		out.print("</table></b></font></div>");
		}
		else
		{
		out.print("<b style='color:#FF0000'>您的身份认证已过期，请重新登录！</b>");
		}
%>
<%
	String msgMess = "";
	Open oo = new Open(id);
	int isOpen = 0;
	if(isLog)
	{
		isOpen = oo.getFunc().get(oo.have(id)).getMsg();
		if(user.equals(name))
		{
			if(isOpen == 0)
			{
			 	msgMess = "亲爱的 <font color='#00FF00'>"+name+"</font>, 想跟自己说两句话吗？<br />快去开通你的留言板吧！";
			}
			else
			{
			 	msgMess = "亲爱的 <font color='#00FF00'>"+name+"</font>, 快给自己说两句话吧！";
			}
		}
		else
		{
			if(isOpen == 0)
			{
			 	msgMess = "您好 <font color='#00FF00'>"+user+"</font>, 有什么话想对<font color='#00FF00'>"+name+"</font>说的嘛？<br />快去叫TA开通留言板吧！";
				out.print("<script></script>");
			}
			else
			{
			 	msgMess = "您好 <font color='#00FF00'>"+user+"</font>, 有什么话想对<font color='#00FF00'>"+name+"</font>说的嘛？";
			}
		}
	}
%>
<div id="warnMess" style="position:absolute;top:150px; width:250px; left:560px;">
     <b style="color:#FF0000"><%=msgMess%></b>
</div>
<div id="sayDiv" style="position:absolute;top:130px; width:250px; left:420px;">
<%
	if(isOpen == 0){
	out.print("<script>document.getElementById('sayDiv').style.display='none';</script>");
	}else{
	out.print("<script>document.getElementById('warnMess').style.top='50px';</script>");
	out.print("<script>document.getElementById('warnMess').style.left='420px';</script>");
	}
%>
<form name="msgForm" action="detail.jsp" method="post">
<div style="width: 250px; height: 60px; border-top: 1px solid; border-left: 1px solid; border-right: 1px solid;">
  <select onchange=document.execCommand('FontSize',false,this.value)>
    <option value=3>3号字</option>
    <option value=4>4号字</option>
    <option value=5>5号字</option>
    <option value=6>6号字</option>
    <option value=7>7号字</option>
  </select>
  <input type=button value="红色" onclick=document.execCommand('ForeColor',false,'#ff0000')>
  <input type=button value="绿色" onclick=document.execCommand('ForeColor',false,'#00ff00')>
  <input type=button value="蓝色" onclick=document.execCommand('ForeColor',false,'#0000ff')>
  <input type=button value="左对齐" onclick="document.execCommand('JustifyLeft')">
  <input type=button value="居中" onclick=document.execCommand('JustifyCenter')>
  <input type=button value="右对齐" onclick=document.execCommand('JustifyRight')>
<!-- to transmission the value of the id -->
  <input type="hidden" name="transid" value="<%=id%>" />
  <input type="hidden" name="id" value="<%=id%>" />
<div id="editArea" contenteditable style="height:180px; width:250px; border:1px solid; overflow-y:auto;"> </div>
<!-- to transmission the value of the txt -->
  <input type="hidden" name="txt" id="txt" />
<div align="right">
	<img src="../image/png-1262.png" onclick="addMsg();" /> 
</div>
</div>
</form>
</div>
<div id="showDiv" style="position:absolute; left:780px; top:20px">
<%
	if(isOpen == 0){
	out.print("<script>document.getElementById('showDiv').style.display='none';</script>");
	}else{
	out.print("<script>document.getElementById('warnMess').style.top='50px';</script>");
	out.print("<script>document.getElementById('warnMess').style.left='420px';</script>");
	}
	Msg_show myShow = null;
	if(isLog&&isOpen!=0)
	{
	 	myShow = new Msg_show(id);
		int count =0;
		if(myShow.getMsg().size() == 0)
		{
			out.print("<font size='+2' color='#FF0000'>还没有人留言呢！<br />来坐沙发先！</font>");
		}
		else
		{
			out.print("<font size='+2' color='#00FF66'>看看朋友们是怎么说TA的！</font>");
		out.print("<table id='people' style='boder-collapse:collapse'><tbody id='peo_name'>");
		for(int temp = 0;temp<myShow.getMsg().size();temp++)
		{
			 out.print("<tr bgcolor='#C2C2C2'><td align='left' width='50px'><font size='+1' color='#D5A242'>"+(temp+1)+"楼</font></td><td align='right' width='150px'><font size='+1' color='#D5A242'>作者:"+myShow.getMsg().get(temp).getAuthor()+"</font></td></tr>");
			 out.print("<tr><td width='200px' colspan='2'>"+myShow.getMsg().get(temp).getTxt()+"</td></tr>");
			 out.print("<tr bgcolor='#C2C2C2'><td width='200px' colspan='2'><font size='+1' color='#FF0000'>"+myShow.getMsg().get(temp).getDate()+"</font></td></tr>");
			 count = temp;
		}
		out.print("</tbody></table>");
		if(count>4)
		{
			out.print("<table><tr><td><a href='#' onclick='page.nextPage();'>下一页</a></td><td><a href='#' onclick='page.prePage();'>上一页</a></td></tr></table>");
		}
		}
	}
%>
</div>
</body>
</html>
<script language="javascript">
var pass = false;
function addMsg()
{
	var msgtxt = document.getElementById("editArea");
	if(msgtxt.innerHTML.trim().length>=1)
	{
		pass = true;
	}
	else
	{
		alert("there shouldn`t be a null input");
	}
	if(pass)
	{
		document.getElementById("txt").value = msgtxt.innerHTML;
		document.msgForm.submit();
	}
}
</script>